package com.xgit.iov.common.core.feign;

import cn.hutool.core.util.StrUtil;
import com.xgit.iov.common.core.constant.SecurityConstants;
import com.xgit.iov.common.core.util.SecurityUtils;
import feign.RequestInterceptor;
import feign.RequestTemplate;

/**
 * @Author: william
 * @Date: 2020/9/28 15:33
 */
public class FeignAuthRequestInterceptor implements RequestInterceptor {

	@Override
	public void apply(RequestTemplate requestTemplate) {
		if(StrUtil.isNotBlank(SecurityUtils.getToken())){
			requestTemplate.header(SecurityConstants.AUTHORIZATION, SecurityConstants.BEARER_TYPE+" "+SecurityUtils.getToken());
		}
	}
}
